<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
<style>
    body{
        display: flex;
        justify-content: center;
        align-items: center;
        height: 500px;
    }
    .triangle:before{
        content: "";
        position: absolute;
        top:15px;
        left: -10px;
        border-top:10px solid transparent;
        border-right:10px solid red;
        border-bottom: 10px solid transparent;
    }
    .triangle{
        width:200px;
        height:50px;
        border:1px solid red;
        position: relative;
        background: yellow;
    }
    /*生成一个伪元素盖住小三角*/
    .triangle:after{
        content: "";
        position: absolute;
        top:15px;
        left: -9px;
        border-top:10px solid transparent;
        border-right:10px solid yellow;
        border-bottom: 10px solid transparent;
    }
</style>
</head>
<body>
    <div class="triangle"></div>
</body>
</html>